package com.gitee.wsl.ext.array

import kotlin.experimental.xor

/**
 * Inverts the current byte array
 * Optionally with [startIndex] and [endIndex]
 */
fun ByteArray.invert(startIndex: Int = 0, endIndex: Int = this.lastIndex): ByteArray {
    for (index in startIndex..endIndex) {
        this[index] = this[index] xor -1
    }
    return this
}
